


INCLUDES= \
	-I $(CIL) \
	-I $(MLHEADER) \

LIBS = \
	-L $(CIL) \
	-L $(MLLIB) \

all: ocaml_type.o cilmod.o cil_stub.o cil_wrap.o
	cp $(MLLIB)/libasmrun.a libcilstub.a
	ar r libcilstub.a ocaml_type.o cilmod.o cil_stub.o cil_wrap.o

ocaml_type.o: ocaml_type.h ocaml_type.c
	gcc $(INCLUDES) $(DEBUG) -c ocaml_type.c 



cilmod.o: cil_mod.ml
	$(MLOPT) -output-obj $(INCLUDES) -o cilmod.o str.cmxa unix.cmxa nums.cmxa cil.cmxa cil_mod.ml

cil_stub.o: ocaml_stub.h cil_stub.template
	echo \#ifndef _CIL_STUB_H_ > cil_stub.h
	echo \#define _CIL_STUB_H_ >>cil_stub.h
	sed 's/DEFINE/DECLARE/g' < cil_stub.template >> cil_stub.h
	echo \#endif >>cil_stub.h
	
	cat cil_stub.template > cil_stub.c	
	
	gcc $(INCLUDES) $(DEBUG) -c cil_stub.c

cil_wrap.o: cil_wrap.h cil_wrap.c
	gcc $(INCLUDES) $(DEBUG) -c cil_wrap.c



    
clean:
	rm -f cil_stub.c cil_stub.h *.cm* *.o *.a



